﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductAdd.aspx.cs" Inherits="CNVP.JShop.Web.Admin.ProductAdd"
    ValidateRequest="false" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta content="IE=7" http-equiv="X-UA-Compatible" />
    <link href="CSS/Edit.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script src="JS/swfobject.js" type="text/javascript"></script>
    <script src="JS/jquery.uploadify.min.js" type="text/javascript"></script>
    <script src="JS/more.upload.js" type="text/javascript"></script>
    <script src="../Scripts/Common.js" type="text/javascript"></script>
    <script type="text/javascript">
        function SetCtrlValue(ctrl, value) {
            var temp = 0;
            $("input[name='" + value + "']").each(
            function () {
                if (temp == 0 || temp > parseFloat($(this).val())) {
                    temp = parseFloat($(this).val());
                }
            }
            );
            $(ctrl).attr("value", temp.toString());
        }
        function SetStockNum() {
            var total = 0;
            $("input[name='StockNum']").each(
            function () {
                total = parseFloat(total) + parseFloat($(this).val());
            }
            );
            $("#txtStockTotalNum").attr("value", total.toString());
        }
        function ProTypeRefBranks() {
            var ddlProductTypeID = document.getElementById("<% =ddlProductTypeID.ClientID %>").value;
            var lbBrandID = document.getElementById("<% =lbBrandID.ClientID %>");
            var lbProBrandID = document.getElementById("<% =lbProBrandID.ClientID %>").innerHTML;
            lbBrandID.innerHTML = GetAjaxResponse("CommonWindows/AjaxBranksIDS.aspx?lbProBrandID=" + lbProBrandID + "&ProductTypeID=" + ddlProductTypeID);

        }
        function ProductType() {
            var ddlProductTypeID = document.getElementById("<% =ddlProductTypeID.ClientID %>").value;
            var lbRefExtendProperty = document.getElementById("lbRefExtendProperty");
            lbRefExtendProperty.innerHTML = GetAjaxResponse("CommonWindows/AjaxProAddRefAll.aspx?ProductID=<%=id %>&TypeStr=RefExtendProperty&ProductTypeID=" + ddlProductTypeID);
            var lbRefDescripttion = document.getElementById("lbRefDescripttion");
            lbRefDescripttion.innerHTML = GetAjaxResponse("CommonWindows/AjaxProAddRefAll.aspx?ProductID=<%=id %>&TypeStr=RefDescripttion&ProductTypeID=" + ddlProductTypeID);
        }
        $(function () {
            $('#custom_file_upload').uploadify({
                'uploader': '/Admin/JS/uploadify.swf',
                'script': '/Admin/Upload.ashx',
                'cancelImg': '',
                'folder': '/UploadFile/Product/',
                'multi': true,
                'auto': true,
                'fileExt': '*.jpg;*.gif;*.png',
                'fileDesc': 'Image Files (.JPG, .GIF, .PNG)',
                'queueID': 'custom-queue',
                'queueSizeLimit': 999,
                'simUploadLimit': 999,
                'buttonText': '选择文件',
                'removeCompleted': false,
                'onSelectOnce': function (event, data) {
                    $('#status-message').text(data.filesSelected + ' 个文件加入上传队列');
                },
                'onComplete': function (event, queueId, fileObj, response, data) {
                    if (response.split('|')[0] == "1") {
                        $("#uploadImgState").html(uploadImg(response.split('|')[1], response.split('|')[2], response.split('|')[3], response.split('|')[4]));
                        var $imgPic = $("#uploadImgState").find("span").first();
                        if ($imgPic) {
                            $imgPic.find("img").first().click(); //.css("border", "1px solid red");
                        }
                    }
                    else {
                        $('#status-message').text(data.filesUploaded + ' 个文件上传失败');
                    }
                },
                'onAllComplete': function (event, data) {
                    $('#status-message').text(data.filesUploaded + ' 个文件已上传');

                }
            });
        });
        $(function () {
            $("#ddlProductClassID").change(
            function () {
                $.post("CommonWindows/AjaxGetReviewStat.aspx", { Cid: $(this).children('option:selected').val() }, function (data) {
                    var json = eval("(" + data + ")");
                    $("input[name=rbAllowReview]").each(function () {
                        if (this.value == json.result) {
                            this.checked = true;
                        }
                        else {
                            this.checked = false;
                        }
                    });
                });
            })
        })

        //热链的产品表的行上移
        function onMoveUp(line) {
            //$(this).preventDefault();
            var table = $("#tableEditPic");
            //var currentContent = $(line).parent().parent().html();
            var currentRow = $(line).parent().parent().find("td:first-child").html();
            
            var upRow = parseInt(currentRow) - 1;
            if (upRow <= 0) {
                return;
            }
            //取得两行的内容
            var upContent = $("#tr" + upRow).html();
            var currentContent = $("#tr" + currentRow).html();
             
            $("#tr" + upRow).html(currentContent);
            //交换当前行与上一行内容
            $("#tr" + currentRow).html(upContent);
            $("#tr" + upRow + " td:first-child").html(upRow);
            $("#tr" + currentRow + " td:first-child").html(currentRow); 
        }

        //热链的产品表的行下移
        function onMoveDown(line) {
            //$(this).preventDefault();
            var trs = $("#tableEditPic>tbody>tr");            
            //var trs = $(line).parent().parent().parent().find("<tr>").length;// $("#tableEdit").find("<tr>");            
            var currentRow = $(line).parent().parent().find("td:first-child").html();
            var downRow = parseInt(currentRow) + 1;
            if (downRow > trs.length) {
                return;
            }
            //取得两行的内容
            var downContent = $("#tr" + downRow).html();
            var currentContent = $("#tr" + currentRow).html();
            $("#tr" + downRow).html(currentContent);
            //交换当前行与上一行内容
            $("#tr" + currentRow).html(downContent);
            $("#tr" + downRow + " td:first-child").html(downRow);
            $("#tr" + currentRow + " td:first-child").html(currentRow);            
            
        }

        //删除热链的产品表的行
        function onDelete(line) {
            if (confirm("你确定要删除该记录吗？")) {
                $(line).parent().parent().remove();
                setTxtHotLink();
            }
        }

        //设置要存储到表的热链产品ID串
        function setTxtHotLink() {
            var value = "";
            var products = $("#tableEditPic input[name='ProductID']");
            //alert(products.length);
            for (var i = 0; i < products.length; i++) {
                //alert($(products[i]).val());
                value += $(products[i]).val();
                value += ",";
            }
            value = value.substring(0, value.length - 1);
            $("#txtHotLink").val(value);
        }
    </script>
</head>
<body onload="ProTypeRefBranks();StartStandardEdit();ProductType();PicAddress();"  >
    <form id="form1" runat="server">
    <div class="Content">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cell">
            <tr>
                <td class="cell_group">
                    <img src="Images/ListIconTitle.jpg" alt="" />&nbsp;您的位置：<asp:Label ID="lbTitle" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
        <table border="0" cellpadding="0" cellspacing="0" class="division">
            <tr>
                <th nowrap="nowrap">
                    所属类别:
                </th>
                <td colspan="3">
                    <asp:DropDownList ID="ddlProductClassID" runat="server" Width="160px">
                        <asp:ListItem Value="0">--请选择产品类别--</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <th>
                    所属类型:
                </th>
                <td>
                    <asp:DropDownList ID="ddlProductTypeID" runat="server" Width="160px">
                    </asp:DropDownList>
                </td>
                <th>
                    品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;牌:
                </th>
                <td>
                    <asp:Label ID="lbBrandID" runat="server"></asp:Label>
                    <asp:Label ID="lbProBrandID" runat="server" CssClass="Display"></asp:Label>
                </td>
            </tr>
            <tr>
                <th>
                    商品名称:
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtProductName" runat="server" Width="300px" MaxLength="50" />
                </td>
            </tr>
            <tr>
                <th>
                    商品编号:
                </th>
                <td>
                    <asp:TextBox ID="txtProductCode" runat="server" MaxLength="50" />
                </td>
                <th>
                    商品标签:
                </th>
                <td>
                    <asp:TextBox ID="txtProductTags" runat="server" MaxLength="50" />
                </td>
            </tr>
            <tr>
                <th>
                    商品关键词:
                </th>
                <td>
                    <asp:TextBox ID="txtKeyWords" runat="server" Width="300px" MaxLength="100" />
                    <br />
                    仅用于在前台、后台筛选商品，多个关键词用竖线"|"分开
                </td>
                <th>
                    计量单位:
                </th>
                <td>
                    <asp:TextBox ID="txtProductUnit" runat="server" MaxLength="50" />
                </td>
            </tr>
            <tr id="TradePrice" runat="server" class="idTradePrice">
                <th>
                    销&nbsp;售&nbsp;价:
                </th>
                <td>
                    <asp:TextBox ID="txtTradePrice" runat="server">0</asp:TextBox>
                </td>
                <th>
                    重&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量:
                </th>
                <td>
                    <asp:TextBox ID="txtProductWeight" runat="server">0</asp:TextBox>
                    克
                </td>
            </tr>
            <tr id="CostPrice" runat="server" class="idCostPrice">
                <th>
                    市&nbsp;场&nbsp;价:
                </th>
                <td>
                    <asp:TextBox ID="txtMarketPrice" runat="server" MaxLength="50">0</asp:TextBox>
                    <br />
                </td>
                <th>
                    库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存:
                </th>
                <td>
                    <asp:TextBox ID="txtStockTotalNum" runat="server">0</asp:TextBox>
                </td>
            </tr>
            <tr id="ProductWeight" runat="server" class="idProductWeight">
                <th>
                    成&nbsp;本&nbsp;价:
                </th>
                <td>
                    <asp:TextBox ID="txtCostPrice" runat="server">0</asp:TextBox>
                    仅供后台使用。
                </td>
                <th>
                    货&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位:
                </th>
                <td>
                    <asp:TextBox ID="txtAllocation" runat="server" MaxLength="50" />
                </td>
            </tr>
            <tr>
                <th>
                    上架销售:
                </th>
                <td>
                    <asp:RadioButtonList ID="rblProductState" runat="server" RepeatDirection="Horizontal"
                        Width="100px" CssClass="RadioButtonListTable">
                        <asp:ListItem Value="1" Selected="True">是</asp:ListItem>
                        <asp:ListItem Value="0">否</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <th>
                    货&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:
                </th>
                <td>
                    <asp:TextBox ID="txtProductNo" runat="server" MaxLength="50" />
                </td>
            </tr>
            <tr>
                <th>
                    允许评论:
                </th>
                <td colspan="3">
                    <asp:RadioButtonList ID="rbAllowReview" runat="server" RepeatDirection="Horizontal"
                        Width="100px" CssClass="RadioButtonListTable">
                        <asp:ListItem Value="1">是</asp:ListItem>
                        <asp:ListItem Value="0" Selected="True">否</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
            </tr>
            <tr>
                <th>
                    运费模板:
                </th>
                <td colspan="3">
                   <asp:DropDownList ID="ddlDeliveryFreight" runat="server" Width="160px">
                        <asp:ListItem Value="0">卖家承担运费</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <th>
                    简&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;介:
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtIntro" runat="server" Height="70px" MaxLength="10" TextMode="MultiLine"
                        Width="450px" />
                    <br />
                    简短的商品介绍,请不要超过2000字
                </td>
            </tr>
            <tr>
                <th>
                    图&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;片:
                </th>
                <td colspan="3">
                    <div id="status-message">
                        请选择要上传的文件:</div>
                    <input id="custom_file_upload" type="file" name="Filedata" />
                    <div id="ImgProLoad">
                        <asp:TextBox ID="txtImgProLoad" runat="server" CssClass="Display"></asp:TextBox>
                    </div>
                    <ul id="uploadImgState" style="margin-left:-30px; margin-top:-5px;">
                        <asp:Literal ID="LiterPic" runat="server"></asp:Literal>
                    </ul>
                    <script type="text/javascript">
                        function PicAddress() {
                            var txtImgProLoad = document.getElementById("txtImgProLoad");
                            var ImgPic = document.getElementsByName("ImgPic");
                            for (var i = 0; i < ImgPic.length; i++) {
                                var PicAddress2 = document.getElementsByName("PicAddressB");
                                if (PicAddress2[i].value == txtImgProLoad.value) {
                                    $("#" + ImgPic[i].id + "").css("border", "1px solid red");
                                }
                            }
                        }
                    </script>
                </td>
            </tr>
            <tr>
                <th>
                    规&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格:
                </th>
                <td colspan="3">
                    <input id="BtAdd" type="button" value="添加一个货品" />
                    <input id="BtDel" type="button" value="删除货品" />
                    <input id="Standard" type="text" name="Standard" runat="server" class="Display" />
                    <input id="StandardName" type="text" name="StandardName" runat="server" class="StandardName"
                        style="display: none;" />
                    <input id="btSelectStandard" type="button" value="开启规格" class="btSelectStandard"
                        onclick="StartStandard()" />
                    <input id="btCloseStandard" type="button" class="btCloseStandard" style="display: none;"
                        value="关闭规格" />
                    <script type="text/javascript">
                                     function StartStandardEdit() {
                                        if(<%=id %>>0)
                                        {
                                             var Standard= document.getElementById("Standard").value;
                                             if(Standard!="")
                                             {
                                                $(".StandardName").css("display", "none");
                                                $(".btSelectStandard").css("display", "none");
                                                $(".btCloseStandard").css("display", "");
                                             }
                                        }
                                     }
                                     function StartStandard() {
                                         var $ddlProductTypeID = $("#ddlProductTypeID");
                                         if ($ddlProductTypeID.val() == "0") {
                                            alert("请选择所属类型！");
                                            $ddlProductTypeID.focus();
                                            return false;
                                         }
                                         var Standard = document.getElementById("Standard").value;
                                         var Url = "CommonWindows/ProductAdd_CommonWindow.aspx?ProductTypeID="+$ddlProductTypeID.val()+"&Standard=" + Standard + "";
                                         var result = window.showModalDialog(encodeURI(Url), 'example04', 'dialogHeight:350px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
                                         //alert(result);
                                         if (result != null) {
                                             var val = result.split("*");
                                             document.getElementById("Standard").value = val[0];
                                             //alert(val[1]);
                                             document.getElementById("StandardName").value = val[1];
                                             $(".StandardName").css("display", "none");
                                             $(".btSelectStandard").css("display", "none");
                                             $(".btCloseStandard").css("display", "");
                                             //主产品
//                                             $(".idTradePrice").css("display", "none");
//                                             $(".idCostPrice").css("display", "none");
//                                             $(".idProductWeight").css("display", "none");
                                             var AddTr = "";
                                             AddTr += "<table id=\"tableEdit\">";
                                             AddTr += "	 <tr>";
                                             AddTr += "	 <td >";
                                             AddTr += "		</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		<input id=\"CKA\" name=\"CKA\" type=\"checkbox\" onclick=\"CKACheck()\" /></td>";
                                             AddTr += "	<td >";
                                             AddTr += "		货号</td>";
                                             AddTr += "	";
                                             var standardvalue = val[1].split(",");
                                             var html="";
                                             for(var i=0;i<standardvalue.length;i++)
                                             {
                                                 html += "	<td >";
                                                 html += standardvalue[i];
                                                 html += "	 </td>";
                                             }
                                             AddTr += html;
                                             AddTr += "	 <td >";
                                             AddTr += "		库存</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		销售价</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		市场价</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		成本价</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		重量</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		货位</td>";
                                             AddTr += "	<td >";
                                             AddTr += "		上架</td>";
                                             AddTr += "</tr>";
                                             AddTr += "</table>";
                                             $("#topEdit").append(AddTr);
                                         }
                                     }
                                     $(function () {
                                         $("#BtAdd").click(function () {
                                             if ($("#Standard").val() == "" || $("#StandardName").val() == "") {
                                                 if(confirm("商品规格未开启，你需要立即开启规则吗？"))
                                                 {
                                                    StartStandard();
                                                 }
                                                 else
                                                 {
                                                    return false;
                                                 }
                                             }
                                             else {
                                                 var Standard = document.getElementById("Standard").value;
                                                 var $table = $("#tableEdit tr");
                                                 var len = $table.length+"add";
                                                 //var len = $table.length;
                                                 var j=$table.length;
                                                 //alert(len);
                                                 var AddTr = "";
                                                 AddTr += "<tr>";
                                                 AddTr += "	<td >" + j + "</td>";
                                                 AddTr += "	<td >";
                                                 AddTr += "		<input id=\"CK\" name=\"CK\" type=\"checkbox\"/><input id=\"CKProDetail\" name=\"CKProDetail\" type=\"checkbox\" checked=\"checked\" class =\"Display\" /></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"ProDetailNo" + len + "\" type=\"text\" name=\"ProDetailNo\" value=\""+$("#txtProductNo").val()+""+j+"\" maxlength=\"50\"  /></td>";
                                                 //获取规格值
                                                 AddTr += GetAjaxResponse("CommonWindows/AjaxStandardValue.aspx?Standard=" + Standard + "&len=" + len + "");

                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"StockNum" + len + "\" onblur=\"SetStockNum();\"   type=\"text\" name=\"StockNum\" class=\"ProDetailinput\" value=\"0\"  /></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"SalePrice" + len + "\" onblur=\"SetCtrlValue('#txtTradePrice',$(this).attr('name'));\"  type=\"text\" name=\"SalePrice\" class=\"ProDetailinput\" value=\""+$("#txtTradePrice").val()+"\"  /></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"MarketPrice" + len + "\" onblur=\"SetCtrlValue('#txtMarketPrice',$(this).attr('name'));\"  type=\"text\" name=\"MarketPrice\" class=\"ProDetailinput\" value=\""+$("#txtMarketPrice").val()+"\"  /></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"CostPrice" + len + "\"  onblur=\"SetCtrlValue('#txtCostPrice',$(this).attr('name'));\"  type=\"text\" name=\"CostPrice\" class=\"ProDetailinput\" value=\""+$("#txtCostPrice").val()+"\"  /></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"ProDetailWeight" + len + "\" type=\"text\" name=\"ProDetailWeight\" class=\"ProDetailinput\" value=\""+$("#txtProductWeight").val()+"\"  /></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "		<input id=\"Allocation" + len + "\" type=\"text\" name=\"Allocation\" class=\"ProDetailinput\" value=\""+$("#txtAllocation").val()+"\" maxlength=\"50\"/></td>";
                                                 AddTr += "	<td>";
                                                 AddTr += "	<select id=\"IsShow" + len + "\" name=\"IsShow\">";
                                                 var value0 = "";
                                                 var value1 = "";
                                                 var rblProductState = $("input[name='rblProductState']:checked").val();
                                                 if(rblProductState=="1")
                                                 {
                                                    value1 = "selected='selected'";
                                                 }
                                                 else
                                                 {
                                                    value0 = "selected='selected'";
                                                 }                                                 
                                                 AddTr += "			<option value=\"1\" "+value1+">是</option>";
                                                 AddTr += "			<option value=\"0\" "+ value0+">否</option>";
                                                 AddTr += "	</select></td>";
                                                 AddTr += "</tr>";
                                                 
                                                 $("#tableEdit").append(AddTr);
                                                 //主产品
                                                 
                                             }
                                         });
                                         $("#btCloseStandard").click(function () {
                                             if (confirm("关闭后现已添加的货品数据将全部丢失，你确定要关闭规格吗！")) {
                                                     $("#tableEdit").remove();
                                                     $(".StandardName").css("display", "none");
                                                     $(".btSelectStandard").css("display", "");
                                                     $(".btCloseStandard").css("display", "none");
                                                     document.getElementById("Standard").value = "";
                                                     document.getElementById("StandardName").value = "";

                                                     //主产品
//                                                     $(".idTradePrice").css("display", "");
//                                                     $(".idCostPrice").css("display", "");
//                                                     $(".idProductWeight").css("display", "");
                                                 }
                                         });
                                         $("#BtDel").click(function () {
                                             if ($("#Standard").val() == "" || $("#StandardName").val() == "") {
                                                 alert("请先开启规格！")
                                                 return false;
                                             }
                                             else
                                             {
                                               if(ifEditCheck()){
                                                 if(confirm("你确定要删除以下记录吗？"))
                                                 {
                                                     $("#tableEdit tr:gt(0)").each(function () {
                                                           if ($(this).find("#CK").get(0).checked == true) {
                                                               $(this).remove();
                                                          }
                                                       });
                                                }
                                               
                                              }
                                               else{
                                                   alert('请选择记录！');
                                                   return false;
                                              }
                                             }
                                           });
                                          
                                     });
                                     function CKACheck()
                                     {
                                        var CKA=document.getElementById("CKA");
                                        var CK=document.getElementsByName("CK");
                                        if(CKA.checked==true)
                                        {
                                            for(var i=0;i<CK.length;i++)
                                            {
                                                 CK[i].checked=true;
                                            }
                                        }
                                        else
                                        {
                                            for(var i=0;i<CK.length;i++)
                                            {
                                                 CK[i].checked=false;
                                            }
                                        }
                                     }
                                     function showtopic(id, len) {
                                         var arr = showModalDialog('StandardValuePic.aspx?len=' + len + '&id=' + id + '', 'example04', 'dialogWidth:600px;dialogHeight:400px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
                                         //alert(arr);
                                         if (arr != null) {
                                             var ss;
                                             ss = arr.split("*")
                                             var picurl = document.getElementById("img" + id + "" + len + "");
                                             var pictext = document.getElementById("text" + id + "" + len + "");
                                             picurl.src = ss[1];
                                             pictext.value = ss[0];
                                         }
                                     }
                    </script>
                </td>
            </tr>
            <tr>
                <th>
                    货品列表:
                </th>
                <td colspan="3">
                    <span id="topEdit">
                        <asp:Label ID="lbtopEdit" runat="server"></asp:Label>
                    </span>
                </td>
            </tr>
        </table>
        <!--Begin属性扩展-->
        <div id="lbRefExtendProperty">
        </div>
        <!--End 属性扩展-->
        <h3 onclick="IsShowFCK()">
            详细介绍(<font color="red" style="cursor: pointer">打开请点击</font>)</h3>
        <table border="0" cellpadding="0" cellspacing="0" class="division">
            <tbody id="divisionFCKeditor" style="display: none;">
                <tr>
                    <td>
                        <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Height="500px">
                        </FCKeditorV2:FCKeditor>
                    </td>
                </tr>
            </tbody>
        </table>
        <asp:CheckBox ID="cbFCKeditorIsShow" runat="server" CssClass="Display" />
        <script type="text/javascript">
            function IsShowFCK() {
                var cbFCKeditorIsShow = document.getElementById("cbFCKeditorIsShow");
                if (cbFCKeditorIsShow.checked == true) {
                    cbFCKeditorIsShow.checked = false;
                    $("#divisionFCKeditor").css("display", "none");
                }
                else {
                    cbFCKeditorIsShow.checked = true;
                    $("#divisionFCKeditor").css("display", "");
                }
            }
        </script>
        <!--Begin属性参数-->
        <div id="lbRefDescripttion">
        </div>
        <!--End属性参数-->
        <h3 onclick="IsShowSEO()">
            SEO优化(<font color="red" style="cursor: pointer">打开请点击</font>)</h3>
        <table border="0" cellpadding="0" cellspacing="0" class="division">
            <tbody id="divisionSEO" style="display: none;">
                <tr>
                    <th>
                        页面标题:
                    </th>
                    <td>
                        <asp:TextBox ID="txtOriginTitle" runat="server" Width="255px" MaxLength="50"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <th>
                        页面关键词:
                    </th>
                    <td>
                        <asp:TextBox ID="txtOriginKey" runat="server" TextMode="MultiLine" Rows="5" Width="455px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <th>
                        页面描述:
                    </th>
                    <td>
                        <asp:TextBox ID="txtOriginDescription" runat="server" TextMode="MultiLine" Rows="5"
                            Width="455px"></asp:TextBox>
                    </td>
                </tr>
            </tbody>
        </table>
        <asp:CheckBox ID="cbSEOIsShow" runat="server" CssClass="Display" />
        <script type="text/javascript">
            function IsShowSEO() {
                var cbSEOIsShow = document.getElementById("cbSEOIsShow");
                if (cbSEOIsShow.checked == true) {
                    cbSEOIsShow.checked = false;
                    $("#divisionSEO").css("display", "none");
                }
                else {
                    cbSEOIsShow.checked = true;
                    $("#divisionSEO").css("display", "");
                }
            }
        </script>
        <script type="text/javascript">
            function KeyNum() {
                var productLength = 0;
                if ($("#txtHotLink").val() != "") {
                    productLength = $("#txtHotLink").val().split(",").length;
                }
                //alert(productLength);
                var inputHotLink = document.getElementById("<% =txtHotLink.ClientID %>").value;

                var Url = "CommonWindows/HotLinkProduct_CommonWindow.aspx";
                var result = window.showModalDialog(encodeURI(Url), 'example05', 'dialogHeight:400px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
                if (result != null) {
                    var HotLink = document.getElementById("txtHotLink").value;
                    ////////////////////////////////////////////
                    var arrayResult = result.split(",");
                    var arrayHotLink = HotLink.split(",");
                    var myAry = [];
                    for (var i = 0; i < arrayResult.length; i++) {
                        if (!arrayHotLink.contains(arrayResult[i]))//数组交叉集
                            myAry.push(arrayResult[i]);
                    }
                    var resultList = "";
                    if (HotLink == "") {
                        resultList = result;
                    }
                    else {
                        if (myAry != "") {
                            resultList = HotLink + "," + myAry;
                        }
                        else {
                            resultList = HotLink;
                        }
                    }
                    document.getElementById("txtHotLink").value = resultList;
                    
                    var Prolist = GetAjaxResponse("CommonWindows/AjaxNewsInfoProductList.aspx?result=" + myAry+"&productLength="+productLength);
                    $("#lbHotProList #tableEditPic").append(Prolist);
                }

            }
            function Del(index) {
                if (confirm("你确定要删除该记录吗？")) {
                    $("#tr" + index + "").remove();
                    var getIdList = "";
                    var ProductID = document.getElementsByName("ProductID");
                    for (var i = 0; i < ProductID.length; i++) {

                        getIdList += ProductID[i].value + ",";
                    }
                    //alert(getIdList);
                    var txtHotLink = document.getElementById("<% =txtHotLink.ClientID %>");
                    txtHotLink.value = getIdList.substring(0, getIdList.length - 1);
                }
            }
                        
        </script>
        <h3>
            热链商品</h3>
        <table border="0" cellpadding="0" cellspacing="0" class="division">
            <tr>
                <th>
                    热链商品:
                </th>
                <td>
                    <asp:TextBox ID="txtHotLink" runat="server" CssClass="Display" />
                    <input id="btSelectPro" type="button" value="增加热链商品" onclick="KeyNum()" />
                    <asp:Label ID="lbHotProList" runat="server"></asp:Label>
                    <div id="AddProductList">
                    </div>
                </td>
            </tr>
        </table>
        <div class="EditBtn">
            <asp:Button ID="btUp" runat="server" Text="提交并返回列表" OnClick="btUp_Click" CssClass="EditBtn"  OnClientClick="setTxtHotLink()"/>
            <asp:Button ID="btUp1" runat="server" Text="提交并继续" CssClass="EditBtn" OnClick="btUp1_Click"   OnClientClick="setTxtHotLink()"/>
            <input type="button" value="取消" onclick="javascript:history.go(-1)" class="EditBtn" />
        </div>
    </div>
    </form>
    <script type="text/javascript">
        $(function () {
            $("#btUp").click(function () {

                var $ddlProductClassID = $("#ddlProductClassID");
                if ($ddlProductClassID.val() == "0") {
                    alert("请选择所属类别！");
                    $ddlProductClassID.focus();
                    return false;
                }
                var $ddlProductTypeID = $("#ddlProductTypeID");
                if ($ddlProductTypeID.val() == "0") {
                    alert("请选择所属类型！");
                    $ddlProductTypeID.focus();
                    return false;
                }
                var $txtProductName = $("#txtProductName");
                if ($txtProductName.val() == "") {
                    alert("请输入商品名称！");
                    $txtProductName.focus();
                    return false;
                }
                var $txtTradePrice = $("#txtTradePrice");
                if (!IsDouble($txtTradePrice.val())) {
                    alert("销售价格式不正确！");
                    $txtTradePrice.focus();
                    return false;
                }
                var $txtMarketPrice = $("#txtMarketPrice");
                if (!IsDouble($txtMarketPrice.val())) {
                    alert("市场价格式不正确！");
                    $txtMarketPrice.focus();
                    return false;
                }
                var $txtCostPrice = $("#txtCostPrice");
                if (!IsDouble($txtCostPrice.val())) {
                    alert("成本价格式不正确！");
                    $txtCostPrice.focus();
                    return false;
                }
                var $txtProductWeight = $("#txtProductWeight");
                if (!IsDouble($txtProductWeight.val())) {
                    alert("重量格式不正确！");
                    $txtProductWeight.focus();
                    return false;
                }
                var $txtStockTotalNum = $("#txtStockTotalNum");
                if (!IsDouble($txtStockTotalNum.val())) {
                    alert("库存格式不正确！");
                    $txtStockTotalNum.focus();
                    return false;
                }
                var $txtIntro = $("#txtIntro");
                if ($txtIntro.val().length > 2000) {
                    alert("简介过长，请不要超过2000字！");
                    $txtIntro.focus();
                    return false;
                }
                if ($("#Standard").val() != "" || $("#StandardName").val() != "") {
                    if (!ifEditCheckName()) {
                        alert("请添加货品！");
                        return false;
                    }
                }
                var Standard = document.getElementById("Standard").value.split(",");
                var StandardName = document.getElementById("StandardName").value.split(",");
                for (var i = 0; i < Standard.length; i++) {
                    var StandardValueID = document.getElementsByName("StandardValueID" + Standard[i] + "");
                    for (var k = 0; k < StandardValueID.length; k++) {
                        //alert(StandardValueID[k].value);
                        if (StandardValueID[k].value == "0" || StandardValueID[k].value == "") {
                            alert("" + StandardName[i] + "请选择！");
                            if (StandardValueID[k].value == "0") {
                                StandardValueID[k].focus();
                            }
                            return false;
                        }
                    }
                }
                var $txtOriginKey = $("#txtOriginKey");
                if ($txtOriginKey.val().length > 100) {
                    alert("页面关键词过长，请不要超过100字！");
                    $txtOriginKey.focus();
                    return false;
                }
                var $txtOriginDescription = $("#txtOriginDescription");
                if ($txtOriginDescription.val().length > 100) {
                    alert("页面描述过长，请不要超过100字！");
                    $txtOriginDescription.focus();
                    return false;
                }

            });
            $("#btUp1").click(function () {

                var $ddlProductClassID = $("#ddlProductClassID");
                if ($ddlProductClassID.val() == "0") {
                    alert("请选择所属类别！");
                    $ddlProductClassID.focus();
                    return false;
                }
                var $ddlProductTypeID = $("#ddlProductTypeID");
                if ($ddlProductTypeID.val() == "0") {
                    alert("请选择所属类型！");
                    $ddlProductTypeID.focus();
                    return false;
                }
                var $txtProductName = $("#txtProductName");
                if ($txtProductName.val() == "") {
                    alert("请输入商品名称！");
                    $txtProductName.focus();
                    return false;
                }
                var $txtTradePrice = $("#txtTradePrice");
                if (!IsDouble($txtTradePrice.val())) {
                    alert("销售价格式不正确！");
                    $txtTradePrice.focus();
                    return false;
                }
                var $txtMarketPrice = $("#txtMarketPrice");
                if (!IsDouble($txtMarketPrice.val())) {
                    alert("市场价格式不正确！");
                    $txtMarketPrice.focus();
                    return false;
                }
                var $txtCostPrice = $("#txtCostPrice");
                if (!IsDouble($txtCostPrice.val())) {
                    alert("成本价格式不正确！");
                    $txtCostPrice.focus();
                    return false;
                }
                var $txtProductWeight = $("#txtProductWeight");
                if (!IsDouble($txtProductWeight.val())) {
                    alert("重量格式不正确！");
                    $txtProductWeight.focus();
                    return false;
                }
                var $txtStockTotalNum = $("#txtStockTotalNum");
                if (!IsDouble($txtStockTotalNum.val())) {
                    alert("库存格式不正确！");
                    $txtStockTotalNum.focus();
                    return false;
                }
                var $txtIntro = $("#txtIntro");
                if ($txtIntro.val().length > 2000) {
                    alert("简介过长，请不要超过2000字！");
                    $txtIntro.focus();
                    return false;
                }
                if ($("#Standard").val() != "" || $("#StandardName").val() != "") {
                    if (!ifEditCheckName()) {
                        alert("请添加货品！");
                        return false;
                    }
                }
                var Standard = document.getElementById("Standard").value.split(",");
                var StandardName = document.getElementById("StandardName").value.split(",");
                for (var i = 0; i < Standard.length; i++) {
                    var StandardValueID = document.getElementsByName("StandardValueID" + Standard[i] + "");
                    for (var k = 0; k < StandardValueID.length; k++) {
                        //alert(StandardValueID[k].value);
                        if (StandardValueID[k].value == "0" || StandardValueID[k].value == "") {
                            alert("" + StandardName[i] + "请选择！");
                            if (StandardValueID[k].value == "0") {
                                StandardValueID[k].focus();
                            }
                            return false;
                        }
                    }
                }
                var $txtOriginKey = $("#txtOriginKey");
                if ($txtOriginKey.val().length > 100) {
                    alert("页面关键词过长，请不要超过100字！");
                    $txtOriginKey.focus();
                    return false;
                }
                var $txtOriginDescription = $("#txtOriginDescription");
                if ($txtOriginDescription.val().length > 100) {
                    alert("页面描述过长，请不要超过100字！");
                    $txtOriginDescription.focus();
                    return false;
                }
            });
        })
    </script>
</body>
</html>
